﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EasyProjects.ClientModel.Entities;
using EasyProjects.Client;

namespace EasyProjects.TimeLogger
{
    public static class ProjectExtender
    {
        #region ProjectStatus
        private static List<ProjectStatus> _projectStatuses;

        /// <summary>
        /// Gets the project statuses.
        /// </summary>
        /// <value>The project statuses.</value>
        private static List<ProjectStatus> ProjectStatuses
        {
            get
            {
                if (_projectStatuses == null)
                    _projectStatuses = ObjectsHelper.Instance.Client.Query<ProjectStatus>().ToList();                    

                return _projectStatuses;
            }
        }

        /// <summary>
        /// Statuses the specified proj.
        /// </summary>
        /// <param name="proj">The proj.</param>
        /// <returns></returns>
        public static ProjectStatus Status(this Project proj)
        {
            return ProjectStatuses.Single(p => p.ProjectStatusID == proj.ProjectStatusID);
        }
        #endregion
    }
}
